"""wjj713 URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, include
from drfapp import views
from rest_framework import routers

from wjj713 import settings

# from drfapp.views import BookRCView, HeroRCView

urlpatterns = [
    # path('admin/', admin.site.urls),


    # 1.顶配所配的路由
    path('books/',views.BOOKView.as_view({"get":"list","post":"create"})),
    # path('book/<int:pk>',views.BOOKView.as_view({"get":"retrieve","put":"update","delete":"destroy"})),
    path('heros/',views.HeroView.as_view({"get":"list","post":"create"})),
    # path('hero/<int:pk>',views.HeroView.as_view({"get":"retrieve","put":"update","delete":"destroy"})),
    #

    # 2.使用ViewSet的方法
    # path('books/',views.BookVIEW.as_view({"get":"list","post":"create"})),
    # path('book/<int:pk>',views.BookVIEW.as_view({"get":"retrieve","put":"update","delete":"destroy"})),
    # path('heros/',views.HeroVIEW.as_view({"get":"list","post":"create"})),
    # path('hero/<int:pk>',views.HeroVIEW.as_view({"get":"retrieve","put":"update","delete":"destroy"}))




    # 3.使用GenericViewSet方法来写
    # path('books/',views.BookRCView.as_view({"get":"list","post":"create"})),
    # path('book/<int:pk>',views.BookRCView.as_view({"get":"retrieve","put":"update","delete":"destroy"})),
    # path('heros/',views.HeroRCView.as_view({"get":"list","post":"create"})),
    # path('hero/<int:pk>',views.HeroRCView.as_view({"get":"retrieve","put":"update","delete":"destroy"}))


    #4. 4.  使用APIView
    # path("books/",views.BookRCView.as_view()),
    # path("books/<int:pk>",views.BookRUD.as_view()),
    # path("heros/",views.HeroRCView.as_view()),
    # path("heros/<int:id>",views.HeroRUD.as_view())

    # 5.第五种方法    用GenericAPIView实现增删改查
    # path("books/",views.BookRCView.as_view()),
    # path("book/<int:pk>",views.BookRUDView.as_view()),
    # path("heros/",views.HeroRCView.as_view()),
    # path("hero/<int:pk>",views.HeroRUDView.as_view())



    #第六种方法     GenericAPIView   加了五大扩展类
    # path("books/",views.BookRCView.as_view()),
    # path("book/<int:pk>",views.BookRUDView.as_view()),
    # path("heros/",views.HeroRCView.as_view()),
    # path("hero/<int:pk>",views.HeroRUDView.as_view())

    #第七种方法     ReadOnlyModelViewSet  查一个和查多个
    # path('books/',views.BookView.as_view({"get":"list"})),
    # path('book/<int:pk>',views.BookView.as_view({"get":"retrieve"})),
    # path('heros/',views.HeroView.as_view({"get":"list"})),
    # path('hero/<int:pk>',views.HeroView.as_view({"get":"retrieve"}))
    #第八种方法      用就九大子视图来写
    # path("books/",views.BookRCView.as_view()),
    # path("book/<int:pk>",views.BookRUDView.as_view()),
    # path("heros/",views.HeroRCView.as_view()),
    # path("hero/<int:pk>",views.HeroRUDView.as_view())


    #最底层的view写的
    # path("books/",views.BookRCView.as_view()),
    # path("books1/<int:id>",views.BookRUD.as_view()),
    # path("heros/",views.HeroRCView.as_view()),
    # path("heros1/<int:id>",views.HeroRUD.as_view()),
    # path("img/",views.ImageView.as_view()),
    # path("imgs/",views.ImageViews.as_view()),
    # static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)[0],

     path('stu/',include('demo.urls'))




]





'''

[<URLPattern '^books/$' [name='book-list']>,
<URLPattern '^books\.(?P<format>[a-z0-9]+)/?$' [name='book-list']>,
<URLPattern '^books/(?P<pk>[^/.]+)/$' [name='book-detail']>,
<URLPattern '^books/(?P<pk>[^/.]+)\.(?P<format>[a-z0-9]+)/?$' [name='book-detail']>, 
<URLPattern '^$' [name='api-root']>, 
<URLPattern '^\.(?P<format>[a-z0-9]+)/?$' [name='api-root']>]

'''
    #1.自动生成路由
# router=routers.DefaultRouter()
# router.register('books',BookRCView)
# print(router.urls)
# urlpatterns+=router.urls


# router=routers.SimpleRouter()
# router.register('heros',HeroRCView)
# print(router.urls)
# urlpatterns+=router.urls
